package com.reyco1.medusa.data
{
	public class Iterator
	{
		private var _collection:*;
		private var _cursor:int;
		
		public function Iterator(collection:*)
		{
			_collection = collection;
			_cursor = 0;
		}
		
		/* public */
		
		public function hasNext():Boolean
		{
			return cursor < collection.length - 1;
		}
		
		public function hasPrevious():Boolean
		{
			return cursor > 0;
		}
		
		public function next():Object
		{
			cursor++;
			return collection is Collection ? collection.getItemAt(cursor) : collection[cursor];
		}
		
		public function previous():Object
		{
			cursor--;
			return collection is Collection ? collection.getItemAt(cursor) : collection[cursor];
		}

		/* properties */
		
		public function get collection():Collection
		{
			return _collection;
		}

		public function set collection(value:Collection):void
		{
			_collection = value;
		}

		public function get cursor():int
		{
			return _cursor;
		}

		public function set cursor(value:int):void
		{
			_cursor = value;
		}
	}
}